home *** CD-ROM | disk | FTP | other *** search
- ü
- AMOS Tutorial - IFF Fonts
- -------------------------
-
- þ
- Part 1 - What is an IFF font?
- Part 2 - How does it work
- Part 3 - Creating an example font
- Part 4 - Creating your own fonts
-
- ù
- This tutorial has been typed out by Andrew "Mushroom" Kellett, of
- Mushroom PD (C) March 1996. All rights reserved. If you wish to use
- this article in any other disk magazine, you must first get my
- permission in writing. I must also receive a FULL copy of the magazine
- that it appears in.
-
- ú
- If you would like to get in touch with me about Extreme AMOS, Mushroom
- PD or any other AMOS related matter, you can get in touch with me at
- the below address. If you decide to telephone, please do it after 7pm,
- when I am not as busy, and no later than 11pm, after all, we all need
- our beauty sleep! The address is :
-
- ÿ
- û
- Andrew "Mushroom" Kellett
- Mushroom PD
- 32 Castleton Crescent
- Gamesley
- Glossop
- Derbyshire
- SK13 9TH
- ENGLAND
-
- ü
- Telephone (01457) 857502 E-Mail: mush@sneech.demon.co.uk
-
- ý
- All letters sent to me will be replied to as soon as possible. As
- well as this tutorial, there are other tutorials available :
-
- û
- Creating AMOS Graphic Equalizers
- Creating Simple Databases
- Creating an AMOS Tracker demo
- Identifying different music formats in AMOS (62K!)
-
-
- ÿ
- þ
- If you would like any of the above tutorials, then you can send me
- an SAE and a disk. If you fill the disk full of your own AMOS games
- and utilitys, either compiled or in source code for inclusion in the
- library, then you need not include the SAE, as I will send you the
- stuff back. Alternatively, you can exchange a disk of your own
- programs for a Mushroom disk in the library. Remember to state the
- Mushroom disk number when ordering.
-
- ù
- Have you written any AMOS tutorials which you would like included
- in Extreme AMOS? They can be of any kind of subject, as long as it is
- AMOS. It could be anything from the use of a simple command, right
- through to a large programming diary you have completed. The address
- to send all of your ASCII files, along with any source code that
- accompany's the tutorial, is listed above. You will receive a FREE
- copy of the first issue that your tutorial appears in.
-
-
-
-
-
- ÿ
- ú
- PART 1
- ~~~~~~
- ü
- What is an IFF font ?
-
- þ
- I daresay you have loaded and played a game, where there is a nice
- attractive font that appears on the screen, to display either the
- instructions or maybe the hi-scores. With a hi-score table, there are
- endless possibilities for the names that you enter into it. One way of
- doing this, is to read a font stored on the disk, but displaying these
- can be a bit slow, so the need for an IFF font is called.
-
- A IFF font is a screen full of letters and numbers, that can be
- called at any time from within the program, to be displayed anywhere
- on any screen. These characters are all coloured in the same style as
- the rest, to classify the screen as an IFF font screen. This screen is
- then packed, and is saved to the disk along with the program. IFF
- fonts use a lot less space than if you just had lot's of screens with
- the IFF font displayed as instructions, or everything placed in a
- sprite bank to be displayed later on.
-
- ÿ
- þ
- There are 2 kinds of IFF font, the first being a simple "Square"
- layout, where each of the characters has the same height and width.
- These are the easiest kinds of font to work with. The second kind of
- font is a non-proportional font, in which the width or height of the
- font can change with each of the characters. These fonts take a little
- more time to prepare, but still look just as good.
-
- Fonts can range from simple 3 or 4 pixel squared images, right
- through to a full screen in size. The number of possibilities that can
- be acheived from the font is endless.
-
-
-
-
-
-
-
-
-
-
- ÿ
- ú
- PART 2
- ~~~~~~
-
- ü
- How does an IFF font work ?
-
- þ
- An IFF font is really very simple to use, in any kind of program.
- The routines which I have supplied you will demonstrate how easy it is
- to install a font into your program. An IFF font is read from a grid
- in memory. Each grid space can either be a "Square" font, or each
- piece can vary in size. The program creates an array with all the X
- and Y coordinates for each of the possible pieces, which is called by
- the other routines. There is also another part to the array which
- contains the width of all the different characters available, which is
- more usefull when the font is non-proportional.
-
- Let me try and give you an example. Let's say that you decided to
- use an array called FONT. The program would create 5 offsets from that
- array, FONTX, FONTY, FONTXX, FONTYY, AND FONTS. FONTX and FONTY
- represent the top left hand coordinates of the top of the character in
- the list. FONTXX and FONTYY hold the bottom right-hand coordinates for
- ÿ
- þ
- the character. FONTS hold the width (in pixels) of the character just
- defined. Another way of doing this, is to eliminate FONTS completely,
- and use the algorythym FONTXX-FONTX, but the way I have described is
- easier to follow.
-
- The next step, is to create a string of all the available
- characters in your font. Let's say "ABCDEFGHIJKLMNOPQRSTUVWXYZ". Now,
- when the INSTR command is used against the letter we are looking for,
- it will return with the number inside the string. Say you were looking
- for the letter "D", then INSTR would return with 4. So, it would use
- the SCREEN COPY FONTX(4),FONTY(4),FONTXX(4),FONTYY(4) To destination..
- and paste the letter "D" into place. It is highly important that the
- string containing all the letters is typed in the same way the
- information is entered into the array, otherwise the letters will
- come out different than what you have requested.
-
- The routines I have developed, have been coded to allow you, the
- user, to apply as little AMOS knowledge as possible. All you have to
- do, is assign the POSX and POSY graphics coordinates on the screen, for
- where you want the text to go, and the string you wish printed. If you
- ÿ
- þ
- decide to use the centring routines, then the POSX coordinate is not
- needed, as the program will automatically work out the position for
- you.
-
- All the routines in ALL my fonts use the same kind of parameters
- for different functions. Some of the routines have scrollers, and
- centering routines, which can easily be called in your programs. The
- variables I tend to use the most are :
-
- û
- TEX$ - The string to be drawn on the screen
- POSX - The X coordinate of the destination of the font
- POSY - The Y coordinate of the destination of the font
- SC$ - The text which is to be scrolled across the screen
- NUM - The character being drawn, according to the array
- _SCREEN - The screen number to be drawn on
-
- þ
- I have eliminated the need to add loads of parameters onto a
- procedure call, saving space in the text buffer, so the program runs
- off the CURRENT settings of all the variables called. It is important
- that you make these values GLOBAL, or SHARED, otherwise they will be
- ÿ
- þ
- read as 0 by the routine.
-
- Any other variables are called from within the routine, and are
- not really all that important. If centering the piece of text, then
- you only need assign the POSY value with the true number, and the TEX$
- string to be displayed. _SCREEN does not need to be changed more than
- once unless you are working on a different screen number.
-
- If using the scroller, you can determine how you would like to
- leave the routine. I usually place a small routine in the code which
- will allow me to leave the routine if the mouse button is pressed, and
- I have taken this out of some of the examples. Remember, CTRL+C will
- break you out of the program, and back to the editor.
-
- If you define the statements as global values, you can also
- maintain the values of the last drawing, which is handy when on an
- options screen for example. You could have "Quit? (Y/N)", and then
- when the key is pressed, you could recall the draw routine and print
- the character, before moving onto the next piece of text.
-
- ÿ
- þ
- One thing which I like about IFF fonts, is the fact that they can
- be used in any screen mode, providing the font has enough colours, and
- does not contain more than the desired screen resolution. This means
- that you can fit more text onto a line if you go into hi-res mode, or
- less, more detailed characters on the screen if you decide to opt for
- a lower resolution.
-
- Because the program uses SCREEN COPY, the results it produces are
- almost instantaneously, especially if there is not much to copy. If
- the font is small and are quite a few lines to be done, then it may
- take a couple of seconds, but it is even faster when compiled. The
- only drawback, is that you can't merge the font onto an already-drawn
- background, as it copy's the black bits from the font screen, over to
- the destination screen. In order to get round that problem, you will
- need to use GET BOB, and PASTE BOB, which is slower to use than SCREEN
- COPY.
-
-
-
-
- ÿ
- ú
- Part 3
- ~~~~~~
-
- ü
- How to create an example font that works
-
- þ
- OK then, I am now going to create a simple program, which will
- first create a non-proportianate font. Also included, is a scroll
- routine, which when activated, will scroll a piece of text across the
- screen using that IFF font.
-
- ý
- Load and run EXAMPLE_01.AMOS
-
- þ
- As you can see, the font scrolls across the screen. If the screen
- was not in DOUBLE BUFFER mode, it would flicker and jump quite badly.
- You can also see all the DATA statements, which make up this kind of
- font. Now, I think it is time for a proportional font.
-
- ý
- Load and run EXAMPLE_02.AMOS
-
- þ
- This is a nice 16 colour font, which means that it can also be
- ÿ
- þ
- used on a hires screen, with some good results. Look at the DATA
- statements, and see how I built up the size array, using the TEMPA and
- TEMPB arrays alongside it. Again, I have chosen to use the scroller
- routine.
-
- Now, I think it is about time I demonstrated how simple it is to
- use the _CEN and _DRAW routines from within a font. The next example
- uses the same font as in example 2, but will centre a few words. If
- you look at the listing in which you need to actually perform the
- task, you will see that you only need to assign 2 values before
- actually running - The text string to be printed, and the vertical
- position of the text. The draw routine is called from within the
- centering routine, but you can actually move this around, and call it
- seperate of the routine.
-
- ý
- Load and run EXAMPLE_03.AMOS
-
- þ
- See, dead simple. The hardest part of the entire thing, is
- defining the font to create. Once the routines are installed, it is so
- easy to use, in all kinds of screenmodes. This fonts work in Hires.
- ÿ
- ú
- Part 4
- ~~~~~~
-
- ü
- How to create your own IFF fonts!
-
- þ
- Hmm, you do need a paint package to do this, although I am sure
- that there is a program somewhere in the library that will actually
- make the data statements for you. If not, I shall get onto making one
- very soon.
-
- First of all, you will need to place all of the possible
- characters onto a single screen, without them lapping over each
- other's boundary's, otherwise you will get ghosted letters appearing
- on the screen. It is best that you use a single screen, to any size
- you need, as you would need to create another element in the font
- arrays in order to determine which screen you are going to copy from.
- Now you will need to go into personal paint, or any other paint
- package that you have, which will allow you to magnify the picture,
- and show the X and Y coordinates of the screen. Now, write down a list
- of all the possible characters available, and get the coordinates by
- ÿ
- þ
- following these instructions :
-
- ü
- Proportional fonts
- ~~~~~~~~~~~~~~~~~~
-
- û
- Simply write down each horizontal coordinate of each letter, by
- letting the crosshairs of the mouse overlap onto the first pixel on
- the top, and the left-hand side of the letter. Write down the
- coordinates. Now do the same for the bottom right of the character,
- but ensure that the crosshairs are NOT overlapping onto any of the
- pixels. You must also write down the 4 coordinates for all the
- characters on the left hand side of the screen, and use an array
- similar to what I used, with the across number of letters going
- across, and the down going down in the loop. Also make a note of the
- width of the character in pixels, to be used instead of NINES()
-
- ü
- Non-Proportional fonts
- ~~~~~~~~~~~~~~~~~~~~~~
-
- û
- Unlike the above, you must write down all 4 coordinates for each
- ÿ
- û
- letter, and also the width (in pixels) of each letter, so the program
- can add the space accordingley. Take the coordinates using the same
- method as above, and draw a line from the left hand side of the char,
- to the right, and the screen should tell you how many pixels it takes
- (before you let go of the mouse). Pressing UNDO should remove the
- line, unless you clicked on something else first.
-
- Once you have all of your coordinates, you can place them into
- DATA statements like I did, spacing them out, with each letter being
- on one line during testing, to iron out any small bugs that you may
- have overlooked. When you know it is working correctly, you can then
- reduce the number of lines.
-
-
- ù
- Well, I think that just about covers it. As you know, every month
- I give away new IFF font programs, so you should never be short of an
- IFF font to use in your own programs. Most of the IFF fonts were drawn
- by people other than myself, yet the program was written by me, so
- remember that in your credits should you decide to use any of my
- routines.
- ÿ
-
- ù
- If you want to know more about any other AMOS subject, then why
- not drop me a line at the above address. I also have other tutorials
- available (all with source) which cover a whole array of different
- subjects :
-
- û
- Graphic Equalizers
- Tracker Tutorial Prt. 1
- Tracker Tutorial Prt. 2
- Databases Prt. 1
- Databases Prt. 2
- IFF Fonts
-
- ø
- You can get any of these tutorials by sending an SAE and a disk,
- or 4 first class stamps, to me at the address above. If you are
- sending a disk, then why not fill it with some AMOS PD so I can place
- it in the library. All letters will be replied to as soon as possible.
-
-
-
- ÿ
- û
- If you would like to contribute any articles to Extreme AMOS, then
- include them on the disk as well. Remember, any articles I use, you
- will receive a FREE copy of the first issue they appear in. I would
- prefer it if you sent AMOS articles, but other things such as reviews
- etc. are welcome.
-
- I would especially like things like programming diaries, and
- routines, which are explained in detail, to cover special FX on the
- screen, or some other form of really usefull routine. The list of
- possibilities is endles !!
-
- ú
- [Andrew "Mushroom" Kellett]
-
- ÷
- EOF
-
-